package day05;

import java.util.Scanner;

/**
 * @author Xiao
 * @date 2021/7/5
 */
public class getMax_02 {
    /*
        需求：
            定义一个方法，求3个整数的最大值
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[3];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个整数：");
            arr[i] = sc.nextInt();
        }
        int max = getMax02(arr);
        System.out.println("max:" + max);
        System.out.println("---------------------");


        System.out.println("max:" +getMax0202(1,2,3));

    }

    private static int getMax02(int[] arr) {
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        return max;
    }
    private static int getMax0202(int a,int b,int c) {
        int temp = a > b ? a : b;
        int max = temp > c ? temp : c;
        return max;
    }
    private static int getMax0203(int a, int b, int c) {
        if(a > b && a > c) {
            return a;
        } else if (b > a && b > c) {
            return b;
        }else {
            return c;
        }
    }
}
